#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "../zjson.h"

#define MAX_LEN 4*1024*1024
int main(int argc, char **argv) {
    if (argc != 2) {
        printf("Usage: zJSON_minify json-file\n");
        exit(EXIT_FAILURE);
    }
    FILE *json_file = fopen(argv[1], "r");
	assert(json_file);
    char *json_str = (char *) malloc(MAX_LEN* sizeof(char));
    memset(json_str, 0, MAX_LEN);
    char *ptr = json_str;
    while ((*(ptr++) = (char) fgetc(json_file)) != EOF);
    jval *json = zJSON_parse(json_str);
    assert(json);
    zJSON_minify(json);
    printf("\n");
    zJSON_free_jval(json);
	free(json_str); 
	fclose(json_file);
    return 0;
}
